package cn.duckerkj.base.datasource;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.util.Assert;

public class DynmicDataSourceContextHolder {  
	private static Logger log = LoggerFactory.getLogger(DynmicDataSourceContextHolder.class); 

	public static final ThreadLocal<String> contextHolder = new ThreadLocal<String>();  
    
    public static String getDataSourceKey() {  
        return contextHolder.get();  
    }  
  
    public static void setDataSourceKey(String dataSourcekey) {  
    	Assert.notNull(dataSourcekey, "dataSource cannot be null");
        contextHolder.set(dataSourcekey);  
    }  
    
    public static void clear() {  
        contextHolder.remove();  
    }
}  
